home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DELPHI / PROGRS10.ZIP / STATDLG.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-12-26  |  2.2 KB  |  90 lines

  1. {
  2.  Unit Name:      StatDlg
  3.  Unit Type:      Dialog
  4.  
  5.  Created:        18 December 1995
  6.  Last Modified:  23 December 1995
  7.  
  8.  Authors:        CNS International B.V.
  9.                  Feel free to use this unit as you like.
  10.  
  11.  Description: This dialog is an example of using the TDBProgress
  12.               component. To use this dialog, perform the following
  13.               actions:
  14.  
  15.               1. Add this file to your project
  16.               2. Add this unit to the 'uses' clause of the
  17.                  units which will be performing database actions
  18.               3. Place 'dlgStatus.Show;' before and 'dlgStatus.Hide;'
  19.                  after the database operations for which you want to
  20.                  provide feedback.
  21.               4. Compile and run.
  22.  }
  23.  
  24. unit StatDlg;
  25.  
  26. interface
  27.  
  28. uses
  29.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  30.   Forms, Dialogs, StdCtrls, Buttons, Gauges, ExtCtrls, DB,
  31.   DBTables, DBProgrs;
  32.  
  33. type
  34.   TdlgStatus = class(TForm)
  35.     panBackground: TPanel;
  36.     gauDBStatus: TGauge;
  37.     cmdAbort: TBitBtn;
  38.     DBProgress1: TDBProgress;
  39.     procedure FormCreate(Sender: TObject);
  40.     procedure cmdAbortClick(Sender: TObject);
  41.     procedure DBProgress1StatusChange(Sender: TObject; var Abort: Boolean);
  42.   private
  43.     { Private declarations }
  44.     bPerformAbort: Boolean;
  45.   public
  46.     { Public declarations }
  47.   end;
  48.  
  49. var
  50.   dlgStatus: TdlgStatus;
  51.  
  52. implementation
  53.  
  54. {$R *.DFM}
  55.  
  56. procedure TdlgStatus.FormCreate(Sender: TObject);
  57. begin
  58.    { Clear abort flag }
  59.    bPerformAbort := False;
  60. end;
  61.  
  62. procedure TdlgStatus.cmdAbortClick(Sender: TObject);
  63. begin
  64.    { Set the Abort flag to true }
  65.    bPerformAbort := True;
  66. end;
  67.  
  68. procedure TdlgStatus.DBProgress1StatusChange(Sender: TObject;
  69.   var Abort: Boolean);
  70. begin
  71.    if DBProgress1.Percentage <> -1 then
  72.    begin
  73.       gauDBStatus.Visible := True;
  74.       gauDBStatus.Progress := DBProgress1.Percentage;
  75.    end
  76.    else
  77.    begin
  78.       gauDBStatus.Visible := False;
  79.       panBackground.Caption := DBProgress1.LastMessage;
  80.    end;
  81.    Abort := bPerformAbort;
  82.    { Reset abort flag after aborting }
  83.    if bPerformAbort then bPerformAbort := False;
  84.    { Make sure abort button can be pressed }
  85.    Application.ProcessMessages;
  86.  
  87. end;
  88.  
  89. end.
  90.